home *** CD-ROM | disk | FTP | other *** search
- /*
- * TSyntaxMemoParser Script
- * ------------------------
- *
- * Author : David Brock
- * Date : October 18 1997
- * Language: ANSI C
- */
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- //
- //
- // Macro definitions. Parameters may be specified and the replacement text terminates with the end of
- // line (watch trailing blanks).
- //
- #define ct_DEFAULT 0
- #define ct_COMMENT_LINE 1
- #define ct_COMMENT_STAR 2
- #define ct_IDENTIFIER 3
- #define ct_STRING 4
- #define ct_NUMBER 5
- #define ct_COMMENT 6
- #define ct_OPERATOR 7
- #define ct_RESERVED 8
- #define ct_CHAR 9
- #define ct_DIRECTIVE 10
- #define ct_MISC 11
- #define ct_KEYWORD 12
- #define ct_HEXNUMBER 13
-
- #define _non_alpha_ '[^_A-Za-z0-9]'
- #define _all_chars_ '[\x00-\xFF]'
- #define _no_chars_ '[]'
- #define _dont_care_ _all_chars_
- #define _DEFAULT_BACKGROUND clWhite
- #define _DEFAULT_FOREGROUND clBlack
-
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%language section
- //
- // Header section. Describes the textual name of the language, case sensitivity and options used by the language.
- //
- %%language
- Name = 'ANSI C'
- Case = __SENSITIVE
- Options = __DEFAULT_OPTIONS
- WordWrapColumn = _EDGE
- Gutter = _DEFAULT_GUTTER
- Anchor = _DEFAULT_START_ANCHOR
- ExampleText = '/* Comment */\n\
- \#include <stdio.h>\n\
- \char *documentation[] = {\n\
- \ "String text\\n"}\n\
- \a >> 2 > 3 ? 4 ? 5\n'
-
- EditableStyles ('Comment', ct_COMMENT),
- ('String', ct_STRING),
- ('Reserved word', ct_KEYWORD),
- ('Operator', ct_MISC),
- ('Identifier', ct_IDENTIFIER),
- ('Directive', ct_DIRECTIVE),
- ('Number', ct_NUMBER),
- ('Default', ct_DEFAULT)
-
-
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%words section
- //
- // Used to specify simple languge keywords. These are constant value lexemes that always contain the same characters
- // and only require the end style to be specified. The words present here will always be tried first. If they fail
- // then the entries in the %%tokens section will be allowed to try a match.
- //
- // %%words table entries have 3 columns:
- // Column 1 Quoted string giving the characters that make up the word
- // Column 2 Quoted string that specifies how the word is terminated
- // Column 3 Token value returned when word is recognised
- //
- %%words
- '++' _dont_care_ ct_OPERATOR
- '--' _dont_care_ ct_OPERATOR
- '+' _dont_care_ ct_OPERATOR
- '-' _dont_care_ ct_OPERATOR
- '*' _dont_care_ ct_OPERATOR
- '/' _dont_care_ ct_OPERATOR
- '&' _dont_care_ ct_OPERATOR
- '!' _dont_care_ ct_OPERATOR
- '~' _dont_care_ ct_OPERATOR
- '%' _dont_care_ ct_OPERATOR
- '>' _dont_care_ ct_OPERATOR
- '<' _dont_care_ ct_OPERATOR
- '>>' _dont_care_ ct_OPERATOR
- '<<' _dont_care_ ct_OPERATOR
- '>=' _dont_care_ ct_OPERATOR
- '<=' _dont_care_ ct_OPERATOR
- '==' _dont_care_ ct_OPERATOR
- '=' _dont_care_ ct_OPERATOR
- '!=' _dont_care_ ct_OPERATOR
- '^' _dont_care_ ct_OPERATOR
- '|' _dont_care_ ct_OPERATOR
- '&&' _dont_care_ ct_OPERATOR
- '||' _dont_care_ ct_OPERATOR
- '?' _dont_care_ ct_OPERATOR
- ':' _dont_care_ ct_OPERATOR
- '+=' _dont_care_ ct_OPERATOR
- '-=' _dont_care_ ct_OPERATOR
- '*=' _dont_care_ ct_OPERATOR
- '/=' _dont_care_ ct_OPERATOR
- '%=' _dont_care_ ct_OPERATOR
- '>>=' _dont_care_ ct_OPERATOR
- '<<=' _dont_care_ ct_OPERATOR
- '&=' _dont_care_ ct_OPERATOR
- '^=' _dont_care_ ct_OPERATOR
- '|=' _dont_care_ ct_OPERATOR
- ';' _dont_care_ ct_MISC
- '(' _dont_care_ ct_MISC
- ')' _dont_care_ ct_MISC
- '[' _dont_care_ ct_MISC
- ']' _dont_care_ ct_MISC
- '{' _dont_care_ ct_MISC
- '}' _dont_care_ ct_MISC
- //'"' _dont_care_ ct_STRING
- //'\'' _dont_care_ ct_CHAR
- '\/*' _dont_care_ ct_COMMENT_STAR
- '\/\/' _dont_care_ ct_COMMENT_LINE
- '#' _dont_care_ ct_DIRECTIVE
- '0' '[xX]' ct_HEXNUMBER
- 'auto' _non_alpha_ ct_KEYWORD
- 'break' _non_alpha_ ct_KEYWORD
- 'case' _non_alpha_ ct_KEYWORD
- 'char' _non_alpha_ ct_KEYWORD
- 'continue' _non_alpha_ ct_KEYWORD
- 'default' _non_alpha_ ct_KEYWORD
- 'do' _non_alpha_ ct_KEYWORD
- 'double' _non_alpha_ ct_KEYWORD
- 'else' _non_alpha_ ct_KEYWORD
- 'entry' _non_alpha_ ct_KEYWORD
- 'extern' _non_alpha_ ct_KEYWORD
- 'float' _non_alpha_ ct_KEYWORD
- 'for' _non_alpha_ ct_KEYWORD
- 'goto' _non_alpha_ ct_KEYWORD
- 'if' _non_alpha_ ct_KEYWORD
- 'int' _non_alpha_ ct_KEYWORD
- 'long' _non_alpha_ ct_KEYWORD
- 'register' _non_alpha_ ct_KEYWORD
- 'return' _non_alpha_ ct_KEYWORD
- 'short' _non_alpha_ ct_KEYWORD
- 'sizeof' _non_alpha_ ct_KEYWORD
- 'static' _non_alpha_ ct_KEYWORD
- 'struct' _non_alpha_ ct_KEYWORD
- 'switch' _non_alpha_ ct_KEYWORD
- 'typedef' _non_alpha_ ct_KEYWORD
- 'union' _non_alpha_ ct_KEYWORD
- 'unsigned' _non_alpha_ ct_KEYWORD
- 'while' _non_alpha_ ct_KEYWORD
-
-
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%handler section
- //
- // The %%handler section gives rules to be applied once an entry in the %%words table has been recognised. Normally
- // no further processing is required but sometimes a token starts with a fixed set of characters but may be followed
- // by a character class rather than a known sequence.
- //
- // %%handler table entries have 4 columns:
- // Column 1 Token value to be processed
- // Column 2 Character specifier that follows recognised word
- // Column 3 Quoted string specifying end sequence
- // Column 4 Whether end sequence is part of lexeme
- //
- // The <character specifier> is defined as:
- // Column 2 A single character specifier or pre-defined system character macro:
- // _PASCAL_CHAR Pascal style character specifier
- // _C_CHAR C style character specifier
- // If the lexeme can optionally have these characters then append '?' to the end
- // of the quoted string.
- // Column 3 Up to 2 characters may be given as a sequence to terminate the lexeme.
- // Characters are specified using a simplified regular expression. If this
- // string is empty then the lexeme will never be matched.
- //
- %%handler
- ct_COMMENT_LINE '[^\n]'? '\n' _discard_
- ct_COMMENT_STAR _all_chars_? '*\/' _use_
- ct_DIRECTIVE '[^\n]'? '\n' _discard_
- ct_HEXNUMBER '[xX0-9A-Fa-f]' '[^0-9a-fA-F]' _discard_
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%tokens section
- //
- // Used to specify how to recognise non-fixed lexemes. Non-fixed lexemes are only tried if the table entries in the
- // %%words section have failed. The non-fixed lexeme is defiened by 5 columns as below:
- // Column 1 Token value
- // Column 2 Single start character specifier
- // Column 3 Single contains character specifier
- // Column 4 End sequence specifier
- // Column 5 Whether end sequence is part of lexeme
- // Pre-defined token styles are implemented. If used they should be specified in Column 2. The implemented ones
- // are:
- // __STD_PASCALSTRING Pascal string -- starts with ' ands with ' and uses '' to represent
- // ' within a string. Does not extend beywond end of line.
- // __STD_IDENTIFIER Standard identifier. Starts with [_a-zA-Z], contains [_a-zA-Z0-9] and ends with
- // a non-alpha numeric character that is not part of the lexeme
- // __STD_NUMBER_OR_FP Integer or floating point constant of syntax:
- // <Digit String> [ '.' <Digit string> ] [ e|E [+-] <Digit string> ]
- //
- %%tokens
- ct_STRING __STD_C_STRING
- ct_CHAR __STD_C_CHAR
- ct_IDENTIFIER __STD_IDENTIFIER
- ct_NUMBER __STD_NUMBER_OR_FP
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%effects section
- //
- // Used to specify the default colors and font styles used for each token
- //
- // Column 1 Token value
- // Column 2 Font styles
- // Column 3 Foreground color
- // Column 4 Background color
- // Column 5 Optional column specifying whether map entry is a 'hotspot'
- //
- // Columns 1-4 must be completed for all rows, Column 5 defaults to non-hotspot.
- //
- %%effects
- ct_DEFAULT [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- ct_IDENTIFIER [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- ct_STRING [fsItalic] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- ct_COMMENT [fsItalic] clBlue _DEFAULT_BACKGROUND
- ct_KEYWORD [fsBold] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
- ct_NUMBER [] clRed _DEFAULT_BACKGROUND
- ct_DIRECTIVE [] clGreen _DEFAULT_BACKGROUND
- ct_MISC [] _DEFAULT_FOREGROUND _DEFAULT_BACKGROUND
-
-
-
- //--------------------------------------------------------------------------------------------------------------------
- //
- // %%map section
- //
- // Used to specify which entry in the %%effects table each token value uses. By default all token values map onto
- // __DEFAULT_TOKEN which is defined as zero. Table has 2 columns:
- // Column 1 Recognised token value
- // Column 2 Map table entry (i.e. %%effects table entry)
- // Normally the %%map table consists of identical value entries.
- %%map
- ct_IDENTIFIER ct_IDENTIFIER
- ct_STRING ct_STRING
- ct_NUMBER ct_NUMBER
- ct_COMMENT ct_COMMENT
- ct_COMMENT_LINE ct_COMMENT
- ct_COMMENT_STAR ct_COMMENT
- ct_KEYWORD ct_KEYWORD
- ct_MISC ct_MISC
- ct_DIRECTIVE ct_DIRECTIVE
- ct_CHAR ct_STRING
- ct_OPERATOR ct_MISC
- ct_HEXNUMBER ct_NUMBER
-
-